import { Component, OnInit, ViewChild } from '@angular/core';
import { PurchaseManageService } from './purchase-manage.service';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalService } from 'ng-zorro-antd/modal';
import { DatePipe } from '@angular/common';
import { SubwarehouseManageService } from '../../basedata-manage/subwarehouse-manage/subwarehouse-manage.service';
import { MaterialRelationService } from '../../basedata-manage/material-relation/material-relation.service';
import { TabManageService } from '../../basedata-manage/tab-manage/tab-manage.service';
import { FormBuilder, FormControl, FormGroup, Validators, ValidatorFn, AbstractControl } from '@angular/forms';
import { NzTreeComponent, findLastNotEmptyNode } from 'ng-zorro-antd';
import { HCommonService } from 'src/app/h-common/h-common.service';
import { from } from 'rxjs';

export function whsAreaValidator(nameRe: RegExp): ValidatorFn {
  return (control: AbstractControl): {[key: string]: any} | null => {
      if(control.value != null)
      {
        const forbidden = nameRe.test(control.value);
        return forbidden ? null : {'msgWhsAreaError': true};
      }
  };
}

@Component({
  selector: 'app-purchase-manage',
  templateUrl: './purchase-manage.component.html',
  styleUrls: ['./purchase-manage.component.scss']
})
export class PurchaseManageComponent implements OnInit {
  @ViewChild("whsAreaMaterialTree", {static : false}) selWhsAreaMaterialTree : NzTreeComponent

  pageSize: number = 10;
  // top search start
  warehousingNote: string = '';
  materialEncoding: string = '';
  materialName: string = '';
  dateRange = [];
  selectedKF: string = '';
  selectedGYS: string = '';
  POCode: string = '';
  selectedJYZT: string = '';
  kfList = [];
  materialKfList = [];
  kqList = [];
  checkStatus = ['不需要检验','待检','合格','不合格','让步放行'];
  bornRoles = {};

  onDateChange(date) {
    let startTime = this.formatDate(date[0]) != null ? this.formatDate(date[0]) : '';
    let endTime = this.formatDate(date[1]) != null ? this.formatDate(date[1]) : '';
    this.dateRange = [startTime, endTime];
    this.submitSearch();
  }
  // 时间格式化
  formatDate(date) {
    return this.datePipe.transform(date, 'yyyy-MM-dd HH:mm:ss');
  }
  selectKF(data) {
    this.selectedKF = data
    this.submitSearch();
  }
  // 获取库房列表
  async getKFList() {
    let data = {
      code: '',
      name: '',
      materialCategory: '',
      page: 0,
      size: 99
    }
    let list: any = await this.SubwarehouseManageService.getKFList(data)
    this.kfList = list.content
  }
  getKQList(warehouseId) {
    for (let i = 0; i < this.kfList.length; i++) {
      if (this.kfList[i].id == warehouseId) {
        this.kqList = this.kfList[i].warehouseAreas
      }
    }
  }
  selectJYZT(data) {
    this.selectedJYZT = data;
    this.submitSearch();
  }
  submitSearch() {
    this.getRKList()
  }
  // top search end

  // table 1 start
  isInBound = false;// 显示直接入库按钮
  isCheckInBound = false;// 显示请检入库按钮
  isShowInOfficeModal = false;// 显示办公用品模态框(和列表字段判断)
  isShowCheckColumn = false;// 显示列表请验相关字段
  isExistCheckId = false;// 是否存在选中数据

  listOfData = [];
  pageIndexTable1: number = 0;
  curPageIndexTable1: number = 1;
  totalSizeTable1: string = '';
  poMaterialId: string = '';
  clickPageRK(data) {
    this.curPageIndexTable1 = data;
    this.pageIndexTable1 = data;
    this.getRKList()
  }
  async getRKList() {
    let data = {
      warehouseId:this.selectedKF,
      inCode:this.warehousingNote,
      startDate:this.dateRange.length > 0 ? this.dateRange[0] : "",
      endDate:this.dateRange.length > 0 ? this.dateRange[1] : "",
      materialCode:this.materialEncoding,
      materialName:this.materialName,
      po:this.POCode,
      providerName:this.selectedGYS,
      checkStatus:this.selectedJYZT,
      page:this.pageIndexTable1 - 1,
      size:this.pageSize
    }
    let list: any = await this.PurchaseManageService.getRKList(data)
    this.listOfData = list.content
    this.totalSizeTable1 = list.totalElements
  }
  selectJSRK(data){
    this.currentRKID = data.id;
    this.poMaterialId = data.materialId;
    this.isExistCheckId = true;
    if (data.isBatch === true && data.isCheck === true){
      this.isCheckInBound = true;
      this.isInBound = false;
    } else{
      this.isInBound = true;
      this.isCheckInBound = false;
    }
    this.isShowInOfficeModal = data.isBatch === true ? false : true;
    this.isShowCheckColumn = data.isBatch === true && data.isCheck === true ? true : false;
    this.getReceiveInfo(this.currentRKID);
    this.getNodesByMaterialId(data.materialId);
  }

  // table 1 end

  // table 2 start

  currentRKID:string = ''
  currentJSRK: number = 1;
  totalSizeJSRK: number = 0;
  listOfAllDataReceive = [];
  chkDetailItem = null;
  // isAllDisplayDataChecked = false;
  // isIndeterminate = false;
  // listOfDisplayDataReceive = [];
  mapOfCheckedId: { [key: string]: boolean } = {};
  numberOfChecked = 0;

  clickPageJSRK(data) {
    this.currentJSRK = data;
    this.getReceiveInfo(this.currentRKID);
  }
  
  checkSingle(data):void{
    this.listOfAllDataReceive.forEach(item => {
      if(item.id !== data.id){
        item.checked = false;
      }
    })
    this.chkDetailItem = data;
  }

  async getReceiveInfo(id){
    let data = {
      foid:id,
      page:this.currentJSRK - 1,
      size:10
    }
    let list: any = await this.PurchaseManageService.getReceiveInfoList(data).subscribe(res => {
      res.content.forEach(item => {
          item.checked = false;
      })
      this.totalSizeJSRK = res.totalElements
      this.listOfAllDataReceive = res.content;
    });
  }
  // currentPageDataChange($event): void {
  //   this.listOfDisplayDataReceive = $event;
  //   this.refreshStatus();
  // }

  // refreshStatus(): void {
  //   this.isAllDisplayDataChecked = this.listOfDisplayDataReceive
  //     .filter(item => !item.disabled)
  //     .every(item => this.mapOfCheckedId[item.id]);
  //   this.isIndeterminate =
  //     this.listOfDisplayDataReceive.filter(item => !item.disabled).some(item => this.mapOfCheckedId[item.id]) &&
  //     !this.isAllDisplayDataChecked;
  //   this.numberOfChecked = this.listOfAllDataReceive.filter(item => this.mapOfCheckedId[item.id]).length;
  // }

  // checkAll(value: boolean): void {
  //   this.listOfDisplayDataReceive.filter(item => !item.disabled).forEach(item => (this.mapOfCheckedId[item.id] = value));
  //   this.refreshStatus();
  // }
  // table 2 end

  //--弹出物料选择部分  
  txtAltCode: any = '';
  txtAltName: any = '';

  isAltVisible: Boolean = false;
  isAltOkLoading: Boolean = false;
  altPageIndex: any = '1';//table当前页
  altPageSize: any = '6';//table每页条数
  altTotalSize: any = '';//总共条数
  altListOfData  = [];
  selMaterialObj = {};
  // table页码点击事件
  altClickPage(current) {
    this.altPageIndex = current
    this.getMaterialData()
  }
  // 获取右侧人员表格
  async getMaterialData() {
    let data = {
        code: this.txtAltCode,
        name: this.txtAltName,
        page: this.altPageIndex - 1 < 0 ? 0 :this.altPageIndex - 1,
        size: this.altPageSize
    }
    let list: any = await this.TabService.getMaterialList(data).subscribe(res => {
      res.content.forEach(item => {
          item.checked = false;
      })
      this.altTotalSize = res.totalElements
      this.altListOfData = res.content;
    });
  }
  getAltSearchData(){
    this.altPageIndex = 1;
    this.getMaterialData();
  }
  showModal(): void {
    this.getMaterialData();
    this.isAltVisible = true;
  }
  altHandleOk(): void {
    let checked = false;
    this.altListOfData.forEach(item=>{
      if(item.checked){
        checked = true;
        this.materialEncoding = item.code;
        this.isAltVisible = false;
      }
    });
    if(!checked){
      this.message.warning("请选择物料！");
    }
    this.submitSearch();
  }
  altHandleCancel(): void {
    this.isAltVisible = false;
  }
  altCheckSingle(data) {
    this.altListOfData.forEach(item => {
      if(item.checked){
        item.checked = false;
      }
    })
    this.selMaterialObj = data;
    data.checked = true;
  }

  // modal 1 start
  boxType: number = 1;
  isShowBox1: boolean = false;
  radioValue = '';
  checkFirstMsg = '';
  isAnxious = 0;
  chkDetailId = '';// 选中详情ID
  showBox() {
    let isExistCheckItem = false;
    this.listOfAllDataReceive.forEach(item=>{
      if(item.checked === true){
        isExistCheckItem = true;
        this.chkDetailId = item.id;
      }
    });
    if(isExistCheckItem){
      this.isShowBox1 = true;
      this.boxType = this.boxType == 1 ? 2 : 1;
      this.PurchaseManageService.getCheckFirst(this.poMaterialId).subscribe(res=>{
        this.checkFirstMsg = res;
      });
    }else{
      this.message.warning("请选择一条入库详细信息！");
    }
  }
  cancelBox1() {
    this.isShowBox1 = false
  }
  okBox1() {
    this.isOkLoading = true;
    setTimeout(() => {
      this.isOkLoading = false;
    }, 1000);
    let data = {
      id: this.chkDetailId,
      isexpedited: this.isAnxious
    };
    this.PurchaseManageService.postCheckStorage(data).subscribe(res => {
      this.isShowBox1 = false;
      this.isOkLoading = false;
      this.getReceiveInfo(this.currentRKID);
    })
  }
  // modal 1 end

  // modal 2 start
  isShowBox2: boolean = false;
  aryRaw = [];
  aryPack = [];
  materialOptions = [
    {
      label: '是否提供送货单',
      value: 'isdeliverylist'
    },
    {
      label: '是否提供COA',
      value: 'iscoa'
    },
    {
      label: '包装数据是否正确',
      value: 'isdatacorrect'
    },
    {
      label: '标签信息是否完整',
      value: 'iscompletetag'
    },
    {
      label: '外包装是否变形或破损',
      value: 'isdamaged'
    }
  ];
  packageStatus = [
    {
      label:'是否提供送货单',
      value:'pcgisdeliverylist'
    },
    {
      label:'包装数是否正确',
      value:'pcgisdatacorrect'
    },
    {
      label:'外包装是否变形或破损',
      value:'pcgisdamaged'
    },
    {
      label:'尺寸误差是否在范围内',
      value:'pcgissizerange'
    },
    {
      label:'颜色是否正确',
      value:'pciscolorcorrect'
    },
    {
      label:'印刷内容是否完整清晰',
      value:'pcgiscompleteprinted'
    }
  ]
  showBox2() {
    let isExistCheckItem = false;
    this.listOfAllDataReceive.forEach(item=>{
      if(item.checked === true){
        isExistCheckItem = true;
        this.chkDetailId = item.id;
        this.chkDetailItem = item;
      }
    });
    if(!isExistCheckItem){
      this.message.warning("请选择一条入库详细信息！");
      return;
    }
    if (this.chkDetailItem.check != null && this.chkDetailItem.check.checkStatus == 1) {
      this.message.warning("待检数据不可以入库！");
    }else{
      this.isShowBox2 = true;
    }
  }
  cancelBox2() {
    this.isShowBox2 = false
  }
  okBox2() {
    let aryAll = this.aryRaw.concat(this.aryPack);
    let data = {
      id: this.chkDetailId,
      iscoa: aryAll.indexOf("iscoa") > -1 ? 1 : 0,
      iscompletetag: aryAll.indexOf("iscompletetag") > -1 ? 1 : 0,
      isdamaged: aryAll.indexOf("isdamaged") > -1 ? 1 : 0,
      isdatacorrect: aryAll.indexOf("isdatacorrect") > -1 ? 1 : 0,
      isdeliverylist: aryAll.indexOf("isdeliverylist") > -1 ? 1 : 0,
      pcgiscompleteprinted: aryAll.indexOf("pcgiscompleteprinted") > -1 ? 1 : 0,
      pcgisdamaged: aryAll.indexOf("pcgisdamaged") > -1 ? 1 : 0,
      pcgisdatacorrect: aryAll.indexOf("pcgisdatacorrect") > -1 ? 1 : 0,
      pcgisdeliverylist: aryAll.indexOf("pcgisdeliverylist") > -1 ? 1 : 0,
      pcgissizerange: aryAll.indexOf("pcgissizerange") > -1 ? 1 : 0,
      pciscolorcorrect: aryAll.indexOf("pciscolorcorrect") > -1 ? 1 : 0
    };
    let checkedItem = this.chkDetailItem;
    if (checkedItem.check != null && checkedItem.check.checkStatus == 1) {
      this.message.warning("待检数据不可以入库！");
      return;
    }
    this.PurchaseManageService.postConfirmStorage(data).subscribe(res => {
      this.isShowBox2 = false;
      this.message.success("确认入库成功！");
      this.getReceiveInfo(this.currentRKID);
      this.submitSearch();
    })
  }
  materialChecked(data) {
    this.aryRaw = data;
  }
  packageChecked(data){
    this.aryPack = data;
  }
  // modal 2 end

  // model 3 start
  
  isShowBox3: boolean = false;
  showBox3() {
    let isExistCheckItem = false;
    this.listOfAllDataReceive.forEach(item=>{
      if(item.checked === true){
        isExistCheckItem = true;
        this.chkDetailId = item.id;
      }
    });
    if(!isExistCheckItem){
      this.message.warning("请选择一条入库详细信息！");
    }else{
      if(this.chkDetailItem.inStatus === 1){
        this.message.warning("该数据已入库，请勿重复操作！");
      }else{
        this.isShowBox3 = true;
      }
    }
  }
  cancelBox3() {
    this.isShowBox3 = false;
  }
  okBox3() {
    let data = {
      id: this.chkDetailId
    };
    this.PurchaseManageService.postDirectStorage(data).subscribe(res => {
      this.isShowBox3 = false;
      this.message.success("直接入库成功！");
      this.getReceiveInfo(this.currentRKID);
      this.submitSearch();
    })
  }
  // model 3 end

  // model 4 start
  isShowBox4 = false;
  txtaReason = '';
  showBox4() {
    let isExistCheckItem = false;
    this.listOfAllDataReceive.forEach(item=>{
      if(item.checked === true){
        isExistCheckItem = true;
        this.chkDetailId = item.id;
      }
    });
    if(!isExistCheckItem){
      this.message.warning("请选择一条入库详细信息！");
    }else{
      this.isShowBox4 = true;
    }
  }
  cancelBox4() {
    this.isShowBox4 = false
  }
  okBox4() {
    let data = {
      id: this.chkDetailId,
      suggestion: this.txtaReason
    };
    if (data.suggestion == '') {
      this.message.warning("请输入拒绝入库原因！");
    } else {
      this.PurchaseManageService.postRefuseStorage(data).subscribe(res => {
        this.isShowBox4 = false;
        this.getReceiveInfo(this.currentRKID);
      })
    }
  }
  // model 4 end

  // 录入物料

  /*-- 办公用品部分 --*/
  showInOffice: boolean = false;
  validateOfficeForm: FormGroup;


  /*-- 其他物料部分 --*/
  showInMaterial: boolean = false;
  validateMaterialForm: FormGroup;

  /*-- 公共部分 --*/
  isOkLoading = false;
  selWhsTree = [];
  hidWarehouseId = '';
  hidWhsAreaId = '';
  editItem = null;
  whsAreaId: String = '';

  showInBound(data): void{
    if(this.isExistCheckId === true){
      if(this.isShowInOfficeModal === true){
        this.showInOffice = true;
        if(data == null){
          this.editItem = null;
          this.kqList = [];
          this.validateOfficeForm.reset({
            selOfficeWarehouse: "",
            selOfficeWhsArea: ""
          });  
          this.hidWarehouseId = '';
          this.hidWhsAreaId = '';
        }else{
          this.validateOfficeForm.patchValue({
            id: data.id,
            txtAdData: data.arrivalDate,
            txtPackNumber: data.weight,
            txtPackSpec: data.packSpec,
            selOfficeWarehouse: data.warehouseId,
            selOfficeWhsArea: data.warehouseAreaId
          })
          this.hidWarehouseId = data.warehouseId;
          this.hidWhsAreaId = data.warehouseAreaId;
          this.getKQList(data.warehouseId);
          this.editItem = data;
        }
      }else{
        this.showInMaterial = true;
        if(data == null){
          this.editItem = null;
          this.validateMaterialForm.reset({
            selMaterialWarehouse: "",
            selMaterialWhsArea: ""
          });   
          this.hidWarehouseId = '';
          this.hidWhsAreaId = '';
        }else{
          this.validateMaterialForm.patchValue({
            id: data.id,
            txtPdData: data.produceDate,
            txtAdData: data.arrivalDate,
            txtSupplierBatch: data.providerBatch,
            txtCodeBatch: data.barcodeBatch,
            txtPackNumber: data.packageNumber,
            txtPackSpec: data.packSpec,
            txtWeight: data.weight,
            txtCheckWeight1: data.spotweight1,
            selMaterialWarehouse: data.warehouseId,
            selMaterialWhsArea: data.warehouseAreaId,
            txtCheckWeight2: data.spotweight2
          })
          this.hidWarehouseId = data.warehouseId;
          this.hidWhsAreaId = data.warehouseAreaId;
          this.editItem = data;
        }
      }
    }else{
      this.message.warning("请选择要操作的入库通知单！");
    }
  }
  handleCancel(): void{
    if(this.isShowInOfficeModal === true){
      this.showInOffice = false;
    }else{
      this.showInMaterial = false;
    }
    this.isOkLoading = false;
  };
  handleOk(): void{
    this.isOkLoading = true;
    setTimeout(() => {
      this.isOkLoading = false;
    }, 1000);
    
    if(this.isShowInOfficeModal === true){
      for (const i in this.validateOfficeForm.controls) {
        this.validateOfficeForm.controls[i].markAsDirty();
        this.validateOfficeForm.controls[i].updateValueAndValidity();
      }
      if (this.validateOfficeForm.status == "VALID") {
        let data = {
          id: 0,
          foid: this.currentRKID,
          arrivalDate:this.formatDate(this.validateOfficeForm.get('txtAdData').value),
          weight:this.validateOfficeForm.get('txtPackNumber').value,
          packSpec:this.validateOfficeForm.get('txtPackSpec').value,
          warehouseId:this.validateOfficeForm.get('selOfficeWarehouse').value,
          warehouseAreaId:this.validateOfficeForm.get('selOfficeWhsArea').value,
        };
        if(this.editItem == null){
          this.postReceiveInfo(data);
        }else{
          data.id = this.editItem.id;
          this.putReceiveInfo(data);
        }
      }
    }else{
      for (const i in this.validateMaterialForm.controls) {
        this.validateMaterialForm.controls[i].markAsDirty();
        this.validateMaterialForm.controls[i].updateValueAndValidity();
      }
      //console.log(this.selWhsAreaMaterialTree.getTreeNodeByKey(this.validateMaterialForm.get('selMaterialWhsArea').value));
      if (this.validateMaterialForm.status == "VALID") {
        let data = {
          id: 0,
          foid: this.currentRKID,
          produceDate:this.formatDate(this.validateMaterialForm.get('txtPdData').value),
          arrivalDate:this.formatDate(this.validateMaterialForm.get('txtAdData').value),
          providerBatch:this.validateMaterialForm.get('txtSupplierBatch').value,
          barcodeBatch:this.validateMaterialForm.get('txtCodeBatch').value,
          packageNumber:this.validateMaterialForm.get('txtPackNumber').value,
          packSpec:this.validateMaterialForm.get('txtPackSpec').value,
          weight:this.validateMaterialForm.get('txtWeight').value,
          spotweight1:this.validateMaterialForm.get('txtCheckWeight1').value,
          spotweight2:this.validateMaterialForm.get('txtCheckWeight2').value,
          warehouseId:this.validateMaterialForm.get('selMaterialWarehouse').value,
          warehouseAreaId:this.validateMaterialForm.get('selMaterialWhsArea').value,
        };
        if(this.editItem == null){
          this.postReceiveInfo(data);
        }else{
          data.id = this.editItem.id;
          this.putReceiveInfo(data);
        }
      }
    }
  };
  selInputKF(data){
    this.getKQList(data);
    this.whsAreaId = '';
    // if(this.isShowInOfficeModal === true){
    //   this.validateOfficeForm.reset({
    //     selOfficeWhsArea: ""
    //   });  
    // }else{

    // }
  }
  async postReceiveInfo(data){
    await this.PurchaseManageService.postReceiveInfo(data).subscribe(res => {
        if(this.isShowInOfficeModal === true){
          this.showInOffice = false;
        }else{
          this.showInMaterial = false;
        }
        this.isOkLoading = false;
        this.getReceiveInfo(this.currentRKID);
    })
  }
  async putReceiveInfo(data){
    await this.PurchaseManageService.putReceiveInfo(data).subscribe(res => {
        if(this.isShowInOfficeModal === true){
          this.showInOffice = false;
        }else{
          this.showInMaterial = false;
        }
        this.isOkLoading = false;
        this.getReceiveInfo(this.currentRKID);
    })
  }
  async delReceiveInfoByIds(data){
    let ids = [];
    ids.push(data.id);
    await this.PurchaseManageService.delReceiveInfoByIds(ids).subscribe(res => {
      this.getReceiveInfo(this.currentRKID);
    })
  }
  printCode(){
    this.message.warning("功能未实行！");
  }
  getCheckFirst(data){
    return this.PurchaseManageService.getCheckFirst(data);
  }

  whsAreaChange($event): void {
    if(/^\d+-\d+$/.test($event)){
        let whsAndArea = $event.split("-");
        if(whsAndArea.length < 2){
            this.message.warning("库房&库区数据有误！");
        }
        this.hidWarehouseId = whsAndArea[0];
        this.hidWhsAreaId = whsAndArea[1];
    }
}
  
  // 获取左侧树状结构
  async getNodes() {
    await this.relationService.getWhsTree().subscribe(res => {
        var newList = res;
        var selWhsList = res;
        for (let i = 0; i < newList.length; i++) {
            newList[i] = {
                key: newList[i].id,
                title: newList[i].name,
                isLeaf: newList[i].warehouseAreas.length > 0 ? false : true,
                children: newList[i].warehouseAreas || []
            }
            if (newList[i].children && newList[i].children != '') {
                //newList[i].isLeaf = false
                let children1 = newList[i].children
                for (let a = 0; a < children1.length; a++) {
                    children1[a] = {
                        key: newList[i].key + "-" + children1[a].id,
                        pId: newList[i].key,
                        pName: newList[i].title,
                        title: children1[a].name,
                        isLeaf: true
                    }
                }
            }
        }
        this.selWhsTree = newList;
    })
  }

  getNodesByMaterialId(materialId){
    this.relationService.findWareByMaterialId({materialId: materialId}).subscribe(res => {
      this.materialKfList = res;
      //this.selWhsTree = this.bindWhsTree(res);
    });
  }
  bindWhsTree(data){
    for (let i = 0; i < data.length; i++) {
      data[i] = {
          key: data[i].id,
          title: data[i].name,
          isLeaf: data[i].warehouseAreas.length > 0 ? false : true,
          children: data[i].warehouseAreas || []
      }
      if (data[i].children && data[i].children != '') {
          //newList[i].isLeaf = false
          let children1 = data[i].children
          for (let a = 0; a < children1.length; a++) {
              let childrenItem = {
                  key: data[i].key + "-" + children1[a].id,
                  pId: data[i].key,
                  pName: data[i].title,
                  title: children1[a] != null ? children1[a].name : '',
                  isLeaf: true
              }
              children1[a] = childrenItem;
          }
      }
    }
    return data;
  }

  // 录入物料
  constructor(
    private PurchaseManageService: PurchaseManageService,
    private message: NzMessageService,
    private modalService: NzModalService,
    private TabService: TabManageService,
    private datePipe: DatePipe,
    private SubwarehouseManageService:SubwarehouseManageService,
    private relationService : MaterialRelationService,
    private fb: FormBuilder,
    private commonService : HCommonService
  ) { }

  ngOnInit(): void {
    /* 获取权限 */
    this.bornRoles = this.commonService.getRoles("purchase");

    this.validateMaterialForm = this.fb.group({
      txtPdData: [null, [Validators.required]],
      txtAdData: [null, [Validators.required]],
      txtSupplierBatch: [null, [Validators.required]],
      txtCodeBatch: [null, [Validators.required]],
      txtPackNumber: [null, [Validators.required]],
      txtPackSpec: [null, [Validators.required]],
      txtWeight: [null, [Validators.required]],
      txtCheckWeight1: [null],
      selMaterialWarehouse: [null, [Validators.required]],
      selMaterialWhsArea: [null, [Validators.required]],
      txtCheckWeight2: [null]
    })
    this.validateOfficeForm = this.fb.group({
      txtAdData: [null, [Validators.required]],
      txtPackNumber: [null, [Validators.required]],
      txtPackSpec: [null, [Validators.required]],
      selOfficeWarehouse: [null, [Validators.required]],
      selOfficeWhsArea: [null, [Validators.required]]
    })

    this.getRKList()
    this.getKFList()
    this.getNodes()
  }

}
